package com.marquis.cloud.controller;

import com.marquis.cloud.entity.AutUser;
import com.marquis.cloud.pagequery.PaginationGrid;
import com.marquis.cloud.utils.JSONUtil;
import com.marquis.cloud.utils.PropertiesUtil;
import com.marquis.cloud.utils.SimpleHttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Controller
public class UserController {

    @RequestMapping(value = "forwordManage")
    public String forwordManage(){
        return "user_manage";
    }

    /**
     *
     * @return
     */
    @RequestMapping(value = "getUserPage")
    @ResponseBody
    public PaginationGrid<AutUser> getUserPage(HttpServletRequest request, @RequestParam Map<String,Object> param){
        PaginationGrid<AutUser> page = new PaginationGrid<>();
        try {
            //请求地址
            String url = "/aut/user/queryUserPage";
            PropertiesUtil propertiesUtil = new PropertiesUtil();
            //网关地址
            String zuul = propertiesUtil.getZuulUrl();
            String data = SimpleHttpRequest.post(zuul+url, param);
            page = JSONUtil.jsonToBean(data, PaginationGrid.class);
        }catch (Exception e){
            e.printStackTrace();
        }
        return page;
    }
}
